package chai.ning.immutable;

public class Monkey {
	
	private final String name ;
	private final char gender ;
	
	public Monkey( String name , char gender ) {
		super();
		this.name = name ;
		this.gender = gender ;
	}
	
	@Override
	public String toString() {
		return "Monkey[name=" + name + ", gender=" + gender + "]";
	}

	public static void main(String[] args) {
		
		Monkey m = new Monkey( "孙悟空" , '男' ); // 此时Monkey实例是 【不可变对象】
		System.out.println( m );
		
		// m.name = "侯某" ; // The final field Monkey.name cannot be assigned
		// m.gender = '女' ;
		
	}

}
